<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<head>
    <title>宠物医院信息管理系统</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" >
	<link rel="stylesheet" type="text/css" href="css/user.css" >
</head>
<body>
	<div class="wrap">
		<div class="user_box">
		<img src="img/logo.jpg" style="width: 100px; margin-left: 110px; margin-bottom: 50px;"/>
  			<ul class="user_input pd-0">
   				<li>
      				<label class="label_box user_name">用户名</label>
      				<input type="text" id='username' class="input_box input_name" name="login_name" placeholder="请输入用户名" >
    			</li>
	    		<li>
	      			<label class="label_box user_password">密码</label>
	      			<input id='password' type="password" class="input_box input_password" name="login_pwd" placeholder="请输入密码">
	    		</li>
  			</ul>
  			
		  	<div class="user_button" id="login">
		    	<a href="" class="btn_submit dologin">登录</a>
		  	</div>
		</div>
        <div class="user_footer">
          Copyright &copy; 2016 <a>xxx项目</a> | 联系电话：400-000-0000        
        </div>
    </div>
    
	<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
	<script type="text/javascript">
	 $(function() {
	        $("#leftnav").load("pubnav.html");
	        addUser();
			
			$.get("../api/hotel/listall",function(data){
				var html = '';
				if (data.code== 0) {
					var arr = data.data;
					for (var i = 0,len = arr.length; i < len; i++) {
						var obj = arr[i];
						html += '<option value="'+obj.id+'">'+obj.name+'</option>';
					}
				} else {
					html += '<option value="-1">请先添加Id</option>';
				}
				
				document.getElementById('hotelId').innerHTML = html;
			});
			
	      });
	      
	      
		       //增加user
		      var addUser = function(){
		      	$('#add_user').click(function(){
					var hotelIdValue = document.getElementById('hotelId').value;
					if (hotelIdValue == '-1') {
						alert("请先添加Id");
						return false;
					}
		      	
			    	  var obj = {};
			    	  obj.method = 'save';
					  obj.username = $('#username').val();
					  obj.password = $('#password').val();
					  obj.sex = $('#sex').val();
					  obj.hotelId = $('#hotelId').val();
			    	  $.post("../api/user/save",obj,function(data){
			    	  	  //console.log(data);
			    	  	  if (data.code==0) {
			    			  window.location.href = 'user.jsp';
			    		  }
			    	  });
		    		  return false;
		    	  });
		      }
	      
	</script>
    
</body>
</html>
